using HKB.Common;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web;
using System.Web.UI.HtmlControls;
namespace HKB.Web
{
	public class Shop_Shop
	{
		private Pagination _pageHand = null;
		private Conn conn = null;
		protected Pagination pageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.P_Object = Language.Get("Shop/ShopName");
					this._pageHand.SQL_Fields = "ShopID,ShopOwnerID,ShopAddress,ShopOwnerName,ShopName,ShopGroupID,ShopRegDate,ShopClick,ShopStatus,ShopCategoryID,\r\nShopOperatorItem,ShopIdentify,ShopProductNum,ShopImageUrl,\r\n(Select ClassName From HLShop_Class WHERE HLShop_Class.ClassID=HLShop_Shop.ShopCategoryID) As ShopClassName,\r\n(Select SaleCrediet From HL_UserInfo WHERE HLShop_Shop.ShopOwnerID=HL_UserInfo.UserID)As SaleCrediet,\r\n(Select GroupName From HL_ShopGroup WHERE HLShop_Shop.ShopGroupID=HL_ShopGroup.ID) AS ShopGroudName,\r\n(Select OICQ From HL_UserInfo Where UserID = ShopOwnerID) As OICQ, RecommendShop,(Select Taobaowangwang From HL_UserInfo Where UserID = ShopOwnerID) As Taobaowangwang,\r\n(Select SaleCrediet From HL_UserInfo Where UserID=ShopOwnerID) As SalerCrediet";
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		protected Pagination SecUrlPageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.P_Object = Language.Get("Shop/ShopName");
					this._pageHand.SQL_Fields = "SecUrl,ShopName,ShopOwnerName,ShopOwnerID,ShopID,IsUseSecUrl";
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		public Shop_Shop()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public Shop_Shop(Conn _conn)
		{
			this.conn = _conn;
		}
		public DataTable GetAllShop(int pageIndex, string WhereStr, string OrderByStr, int pagesize)
		{
			return this.pageHand.GetDataTable("HLShop_Shop", pageIndex, pagesize, "ShopID", WhereStr, OrderByStr, this.conn, null);
		}
		public DataTable GetAllShop(int pageIndex, string WhereStr, string OrderByStr, int pagesize, params IDbDataParameter[] param)
		{
			return this.pageHand.GetDataTable("HLShop_Shop", pageIndex, pagesize, "ShopID", WhereStr, OrderByStr, this.conn, param);
		}
		public DataTable GetAllSecUrl(int pageIndex, string WhereStr, string OrderByStr, int pagesize)
		{
			return this.SecUrlPageHand.GetDataTable("HLShop_Shop", pageIndex, pagesize, "ShopID", WhereStr, OrderByStr, this.conn, null);
		}
		public DataTable GetAllSecUrl(int pageIndex, string WhereStr, string OrderByStr, int pagesize, params IDbDataParameter[] param)
		{
			return this.SecUrlPageHand.GetDataTable("HLShop_Shop", pageIndex, pagesize, "ShopID", WhereStr, OrderByStr, this.conn, param);
		}
		public DataTable GetHLShopBySearch(int pageIndex, int PageSize, string SearchShopName, string SearchSalerName, string Province, string classID)
		{
			string text = "select top (@PageSize) * from HLShop_Shop where ShopIdentify=1 and  ShopStatus=1 and ShopID not in (select top (@pageIndex) ShopID from HLShop_Shop where ShopIdentify=1 and  ShopStatus=1  order by ShopID desc) ";
			ArrayList arrayList = new ArrayList();
			arrayList.Add(this.conn.CreateParameter("@PageSize", DbType.Int32, PageSize));
			arrayList.Add(this.conn.CreateParameter("@pageIndex", DbType.Int32, (pageIndex - 1) * PageSize));
			if (!string.IsNullOrEmpty(SearchShopName) || SearchShopName != "" || SearchShopName != "-1")
			{
				text += "  and ShopName like '%'+@ShopName+'%'";
				arrayList.Add(this.conn.CreateParameter("@ShopName", DbType.String, SearchShopName));
			}
			if (SearchSalerName != string.Empty || SearchSalerName != "")
			{
				text += "  and ShopOwnerID in (Select UserID From HL_User Where UserName like '%' + @ShopOwnerName + '%')";
				arrayList.Add(this.conn.CreateParameter("@ShopOwnerName", DbType.String, SearchSalerName));
			}
			if (Province != "请选择")
			{
				text += "  and Province like '%' + @Province + '%'";
				arrayList.Add(this.conn.CreateParameter("@Province", DbType.String, Province));
			}
			if (!string.IsNullOrEmpty(classID) && classID != "0")
			{
				text += " and ShopCategoryID=@ShopCategoryID";
				arrayList.Add(this.conn.CreateParameter("@ShopCategoryID", DbType.Int32, Convert.ToInt32(classID)));
			}
			if (text != string.Empty)
			{
				text += " order by ShopID desc";
			}
			DataTable dataTable;
			if (arrayList.Count > 0)
			{
				IDbDataParameter[] array = new IDbDataParameter[arrayList.Count];
				arrayList.CopyTo(array, 0);
				dataTable = this.conn.GetDataTable(text, array);
			}
			else
			{
				dataTable = this.conn.GetDataTable(text);
			}
			return dataTable;
		}
		public DataTable GetHLShopCount(string SearchShopName, string SearchSalerName, string Province, string classID)
		{
			string text = "select * from HLShop_Shop where ShopIdentify=1 and  ShopStatus=1 ";
			ArrayList arrayList = new ArrayList();
			if (!string.IsNullOrEmpty(SearchShopName) || SearchShopName != "" || SearchShopName != "-1")
			{
				text += "  and ShopName like '%'+@ShopName+'%'";
				arrayList.Add(this.conn.CreateParameter("@ShopName", DbType.String, SearchShopName));
			}
			if (SearchSalerName != string.Empty || SearchSalerName != "")
			{
				text += "  and ShopOwnerID in (Select UserID From HL_User Where UserName like '%' + @ShopOwnerName + '%')";
				arrayList.Add(this.conn.CreateParameter("@ShopOwnerName", DbType.String, SearchSalerName));
			}
			if (Province != "请选择")
			{
				text += "  and Province like '%' + @Province + '%'";
				arrayList.Add(this.conn.CreateParameter("@Province", DbType.String, Province));
			}
			if (!string.IsNullOrEmpty(classID) && classID != "0")
			{
				text += " and ShopCategoryID=@ShopCategoryID";
				arrayList.Add(this.conn.CreateParameter("@ShopCategoryID", DbType.Int32, Convert.ToInt32(classID)));
			}
			DataTable dataTable;
			if (arrayList.Count > 0)
			{
				IDbDataParameter[] array = new IDbDataParameter[arrayList.Count];
				arrayList.CopyTo(array, 0);
				dataTable = this.conn.GetDataTable(text, array);
			}
			else
			{
				dataTable = this.conn.GetDataTable(text);
			}
			return dataTable;
		}
		public int GetProductCountByShopID(int ShopID)
		{
			return this.conn.GetDataTable("select * from HLShop_Product where ShopID=" + ShopID).Rows.Count;
		}
		public string GetPagePanel(string linkHead)
		{
			this.pageHand.P_LinkHead = linkHead;
			return this.pageHand.ShowPagePanel();
		}
		public string GetUrlPagePanel(string linkHerd)
		{
			this.SecUrlPageHand.P_LinkHead = linkHerd;
			return this.SecUrlPageHand.ShowPagePanel();
		}
		public DataTable GetShopByShopID(int ShopID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ShopID", DbType.Int32, ShopID);
			return this.conn.GetDataTable("Select * From [HLShop_Shop] Where ShopID = @ShopID", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public DataTable GetShopByShopCategoryID(int ShopID)
		{
			return this.GetShopByShopID(ShopID);
		}
		public DataTable GetLevelShop(int ShopGroupID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ShopGroupID", DbType.Int32, ShopGroupID);
			return this.conn.GetDataTable("Select * From [HLShop_Shop] Where ShopGroupID = @ShopGroupID", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public int GetShopIDByShopOwerID(int UserID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@UserID", DbType.Int32, UserID);
			int result = 0;
			try
			{
				result = (int)this.conn.GetScalar("Select ShopID From [HLShop_Shop] Where ShopOwnerID = @UserID", new IDbDataParameter[]
				{
					dbDataParameter
				});
			}
			catch
			{
				result = 0;
			}
			return result;
		}
		public bool UpdateShopClick(int shopid)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ShopID", DbType.Int32, shopid);
			return this.conn.Execute("UPDATE [HLShop_Shop] Set ShopClick=ShopClick+1 Where ShopID = @ShopID", new IDbDataParameter[]
			{
				dbDataParameter
			}) >= 1;
		}
		public bool UpdateBaseShop(string ShopName, string ShopAnnouncement, string ShopIntro, int ShopCateGoryID, string ShopImageUrl, string ShopAdUrl, string ShopOperatorItem, int ShopID, string ShopAddress, int ShopStatus, int ShopIdentify, string SecUrl)
		{
			ArrayList arrayList = new ArrayList();
			arrayList.Add(this.conn.CreateParameter("@ShopName", DbType.String, ShopName));
			arrayList.Add(this.conn.CreateParameter("@ShopID", DbType.Int32, ShopID));
			arrayList.Add(this.conn.CreateParameter("@ShopAnnouncement", DbType.String, ShopAnnouncement));
			arrayList.Add(this.conn.CreateParameter("@ShopIntro", DbType.String, ShopIntro));
			arrayList.Add(this.conn.CreateParameter("@ShopCategoryID", DbType.Int32, ShopCateGoryID));
			arrayList.Add(this.conn.CreateParameter("@ShopStatus", DbType.Int32, ShopStatus));
			arrayList.Add(this.conn.CreateParameter("@ShopOperatorItem", DbType.String, ShopOperatorItem));
			arrayList.Add(this.conn.CreateParameter("@SecUrl", DbType.String, SecUrl));
			if (ShopImageUrl != "")
			{
				arrayList.Add(this.conn.CreateParameter("@LogoPath", DbType.String, ShopImageUrl));
				arrayList.Add(this.conn.CreateParameter("@ShopImageUrl", DbType.String, ShopImageUrl));
			}
			if (ShopAdUrl != "")
			{
				arrayList.Add(this.conn.CreateParameter("@ShopAdUrl", DbType.String, ShopAdUrl));
			}
			if (ShopAddress != "")
			{
				arrayList.Add(this.conn.CreateParameter("@ShopAddress", DbType.String, ShopAddress));
			}
			IDbDataParameter[] array = new IDbDataParameter[arrayList.Count];
			arrayList.CopyTo(array, 0);
			string text = "UPDATE [HLShop_Shop] SET [ShopName] = @ShopName,SecUrl = @SecUrl, ShopIntro=@ShopIntro,";
			text += "[ShopAnnouncement] = @ShopAnnouncement, [ShopCategoryID] = @ShopCategoryID, ";
			if (ShopImageUrl != "")
			{
				text += "ShopImageUrl = @ShopImageUrl, ";
			}
			if (ShopAddress != "")
			{
				text += "ShopAddress = @ShopAddress, ";
			}
			if (ShopAdUrl != "")
			{
				text += "[ShopAdUrl] = @ShopAdUrl, ";
			}
			object obj = text;
			text = string.Concat(new object[]
			{
				obj,
				"ShopStatus = @ShopStatus,[ShopOperatorItem] = @ShopOperatorItem, ShopIdentify=",
				ShopIdentify,
				" WHERE (([ShopID] = @ShopID))"
			});
			int num = this.conn.Execute(text, array);
			return num == 1;
		}
		public bool UpdateShop(string ShopName, string ShopAnnouncement, string ShopIntro, int ShopCateGoryID, string ShopImageUrl, string ShopOperatorItem, int ShopID, string ShopAddress, int ShopStatus, bool RecommendShop, DateTime LastTimeLogin, string ShopAdUrl, string ShopOwnerName, int ShopClick, DateTime ShopCloseDate, string ShopHelp, int ShopIdentify, DateTime ShopRegDate, string ShopStyle, string ShopTemplateID, string ShopURL, bool IsTax, double Tax, int ShopGroupID, int ShopCredit, string province, string city, string area)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@ShopName", DbType.String, ShopName),
				this.conn.CreateParameter("@ShopOwnerName", DbType.String, ShopOwnerName),
				this.conn.CreateParameter("@ShopAdUrl", DbType.String, ShopAdUrl),
				this.conn.CreateParameter("@ShopAnnouncement", DbType.String, ShopAnnouncement),
				this.conn.CreateParameter("@ShopGroupID", DbType.Int32, ShopGroupID),
				this.conn.CreateParameter("@ShopRegDate", DbType.DateTime, ShopRegDate),
				this.conn.CreateParameter("@ShopCloseDate", DbType.DateTime, ShopCloseDate),
				this.conn.CreateParameter("@ShopClick", DbType.String, ShopClick),
				this.conn.CreateParameter("@ShopHelp", DbType.String, ShopHelp),
				this.conn.CreateParameter("@ShopIntro", DbType.String, ShopIntro),
				this.conn.CreateParameter("@ShopCredit", DbType.Int32, ShopCredit),
				this.conn.CreateParameter("@ShopStatus", DbType.String, ShopStatus),
				this.conn.CreateParameter("@ShopTemplateID", DbType.String, ShopTemplateID),
				this.conn.CreateParameter("@ShopStyle", DbType.String, ShopStyle),
				this.conn.CreateParameter("@ShopCategoryID", DbType.Int32, ShopCateGoryID),
				this.conn.CreateParameter("@ShopImageUrl", DbType.String, ShopImageUrl),
				this.conn.CreateParameter("@RecommendShop", DbType.Boolean, RecommendShop),
				this.conn.CreateParameter("@LastTimeLogin", DbType.DateTime, LastTimeLogin),
				this.conn.CreateParameter("@ShopOperatorItem", DbType.String, ShopOperatorItem),
				this.conn.CreateParameter("@ShopURL", DbType.String, ShopURL),
				this.conn.CreateParameter("@ShopIdentify", DbType.String, ShopIdentify),
				this.conn.CreateParameter("@Tax", DbType.Double, Tax),
				this.conn.CreateParameter("@IsTax", DbType.Boolean, IsTax),
				this.conn.CreateParameter("@ShopAddress", DbType.String, ShopAddress),
				this.conn.CreateParameter("@Original_ShopID", DbType.Int32, ShopID),
				this.conn.CreateParameter("@Province", SqlDbType.NVarChar, province),
				this.conn.CreateParameter("@City", SqlDbType.NVarChar, city),
				this.conn.CreateParameter("@Area", SqlDbType.NVarChar, area)
			};
			string commandText = "UPDATE [HLShop_Shop] SET [ShopOwnerName] = @ShopOwnerName, [ShopName] = @ShopName, [ShopAdUrl] = @ShopAdUrl, [ShopAnnouncement] = @ShopAnnouncement, [ShopGroupID] = @ShopGroupID, [ShopRegDate] = @ShopRegDate, [ShopCloseDate] = @ShopCloseDate, [ShopClick] = @ShopClick, [ShopHelp] = @ShopHelp, [ShopIntro] = @ShopIntro, [ShopCredit] = @ShopCredit, [ShopStatus] = @ShopStatus, [ShopTemplateID] = @ShopTemplateID, [ShopStyle] = @ShopStyle, [ShopCategoryID] = @ShopCategoryID, [ShopImageUrl] = @ShopImageUrl, [RecommendShop] = @RecommendShop, [LastTimeLogin] = @LastTimeLogin, [ShopOperatorItem] = @ShopOperatorItem, [ShopURL] = @ShopURL, [ShopIdentify] = @ShopIdentify, [Tax] = @Tax, [IsTax] = @IsTax, [ShopAddress] = @ShopAddress,Province=@Province,City=@City,Area=@Area WHERE (([ShopID] = @Original_ShopID))";
			int num = this.conn.Execute(commandText, parameters);
			return num == 1;
		}
		public bool UpdateShopTem(string ShopTemplateID, string ShopStyle, int ShopID)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@ShopTemplateID", DbType.String, ShopTemplateID),
				this.conn.CreateParameter("@ShopStyle", DbType.String, ShopStyle)
			};
			int num = this.conn.Execute("Update HLShop_Shop Set ShopTemplateID=@ShopTemplateID, ShopStyle=@ShopStyle Where ShopID=" + ShopID, parameters);
			return num >= 1;
		}
		public bool UpdateShopTem(string ShopStyle, int ShopID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ShopStyle", DbType.String, ShopStyle);
			int num = this.conn.Execute("Update HLShop_Shop Set ShopStyle=@ShopStyle Where ShopID=" + ShopID, new IDbDataParameter[]
			{
				dbDataParameter
			});
			return num >= 1;
		}
		public bool UpdateCountShopProductNum(int ShopProductNum, int UserID)
		{
			int num = this.conn.Execute(string.Concat(new object[]
			{
				"Update HLShop_Shop Set ShopProductNum=",
				ShopProductNum,
				" Where ShopOwnerID=",
				UserID
			}));
			return num >= 1;
		}
		public DataTable AddNewShop(int ShopOwnerID, string ShopName, string ShopAdUrl, string ShopAnnouncement, string ShopIntro, int ShopCategoryID, string ShopImageUrl, int ShopIdentify, string ShopOperatorItem, string ShopOwnerName, string ShopAdd, int shopstatus, string path, string province, string city, string area)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			bool flag = false;
			DateTime now = DateTime.Now;
			DateTime dateTime = DateTime.Now.AddDays(1000.0);
			int num4 = 1;
			string value = "";
			string value2 = "blue";
			float num5 = 0f;
			bool flag2 = false;
			int num6 = 0;
			DateTime now2 = DateTime.Now;
			string value3 = "";
			int num7 = 0;
			int num8 = 0;
			try
			{
				num8 = (int)this.conn.GetScalar("Select top 1 ID From HL_ShopGroup Order By ID Asc", new IDbDataParameter[0]);
			}
			catch
			{
			}
			SqlParameter[] parameters = new SqlParameter[]
			{
				this.conn.CreateParameter("@ShopOwnerID", SqlDbType.Int, ShopOwnerID),
				this.conn.CreateParameter("@ShopName", SqlDbType.NVarChar, ShopName),
				this.conn.CreateParameter("@ShopAdUrl", SqlDbType.NText, ShopAdUrl),
				this.conn.CreateParameter("@ShopAnnouncement", SqlDbType.NText, ShopAnnouncement),
				this.conn.CreateParameter("@ShopGroupID", SqlDbType.Int, num8),
				this.conn.CreateParameter("@ShopRegDate", SqlDbType.DateTime, now),
				this.conn.CreateParameter("@ShopCloseDate", SqlDbType.DateTime, dateTime),
				this.conn.CreateParameter("@ShopClick", SqlDbType.Int, num),
				this.conn.CreateParameter("@ShopHelp", SqlDbType.NText, value),
				this.conn.CreateParameter("@ShopIntro", SqlDbType.NText, ShopIntro),
				this.conn.CreateParameter("@ShopCredit", SqlDbType.Int, num2),
				this.conn.CreateParameter("@ShopStatus", SqlDbType.Int, shopstatus),
				this.conn.CreateParameter("@ShopTemplateID", SqlDbType.NVarChar, num4),
				this.conn.CreateParameter("@ShopStyle", SqlDbType.NVarChar, value2),
				this.conn.CreateParameter("@ShopCategoryID", SqlDbType.Int, ShopCategoryID),
				this.conn.CreateParameter("@ShopChildID", SqlDbType.Int, num3),
				this.conn.CreateParameter("@ShopImageUrl", SqlDbType.NVarChar, ShopImageUrl),
				this.conn.CreateParameter("@RecommendShop", SqlDbType.Bit, flag),
				this.conn.CreateParameter("@Tax", SqlDbType.Float, num5),
				this.conn.CreateParameter("@IsTax", SqlDbType.Int, flag2),
				this.conn.CreateParameter("@ZipCode", SqlDbType.NVarChar, num6),
				this.conn.CreateParameter("@ShopAddress", SqlDbType.NVarChar, ShopAdd),
				this.conn.CreateParameter("@LastTimeLogin", SqlDbType.DateTime, now2),
				this.conn.CreateParameter("@ShopOperatorItem", SqlDbType.NVarChar, ShopOperatorItem),
				this.conn.CreateParameter("@ShopProductClassID", SqlDbType.Int, num7),
				this.conn.CreateParameter("@ShopURL", SqlDbType.NVarChar, value3),
				this.conn.CreateParameter("@ShopIdentify", SqlDbType.Int, ShopIdentify),
				this.conn.CreateParameter("@ShopOwnerName", SqlDbType.NVarChar, ShopOwnerName),
				this.conn.CreateParameter("@CSSID", SqlDbType.Int, 3),
				this.conn.CreateParameter("@LogoPath", SqlDbType.NVarChar, ShopAdUrl),
				this.conn.CreateParameter("@BackgroundImage", SqlDbType.NVarChar, ""),
				this.conn.CreateParameter("@Province", SqlDbType.NVarChar, province),
				this.conn.CreateParameter("@City", SqlDbType.NVarChar, city),
				this.conn.CreateParameter("@Area", SqlDbType.NVarChar, area)
			};
			DataTable dataTable = this.conn.GetDataTable("PR_AddShop", parameters);
			if (dataTable.Rows.Count > 0)
			{
				int num9 = int.Parse(dataTable.Rows[0]["ShopID"].ToString());
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,ClassID,Pricerange1,Pricerange2,ShowProductNum,ShowType)");
				stringBuilder.Append(" values(1,'产品的排行榜'," + num9 + ",-1,0,0,6,'topSelling')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,Keyword)  values(3,'店内搜索'," + num9 + ",'')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID)");
				stringBuilder.Append(" values(4,'图片轮廓'," + int.Parse(dataTable.Rows[0]["ShopID"].ToString()) + ")");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,Picturesize,ShowProductNum,Sortingway)");
				stringBuilder.Append(" values(5,'产品推荐'," + num9 + ",120,4,'NewOn')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,PostsShowType,ShowPostsNum)");
				stringBuilder.Append(" values(6,'店内交流'," + num9 + ",1,4)");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,Keyword,ClassID,ProductType,");
				stringBuilder.Append("Pricerange1,Pricerange2,Picturesize,ShowProductNum,Sortingway) values(7,'产品列表'," + num9 + ",");
				stringBuilder.Append("'',-1,-1,0,0,120,10,'Humanspirit')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,CustomizeComment) values");
				stringBuilder.Append(" (8,'顶部自定义'," + num9 + ",'')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,CustomizeComment) values");
				stringBuilder.Append(" (9,'左边自定义'," + num9 + ",'')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append("insert into HLMall_StoreModule(ModuleID,ModuleName,ShopID,CustomizeComment) values");
				stringBuilder.Append(" (10,'右边自定义'," + num9 + ",'')");
				this.conn.Execute(stringBuilder.ToString());
				stringBuilder.Remove(0, stringBuilder.Length);
			}
			return dataTable;
		}
		public void CreateShopFile(int ShopID)
		{
			string text = HttpContext.Current.Server.MapPath("~/") + "Shop\\" + ShopID.ToString();
			string newDirectoryStr = text + "\\Index.aspx";
			string oldDirectoryStr = HttpContext.Current.Server.MapPath("~/") + "Shop\\Default\\Index.aspx";
			FileIO fileIO = new FileIO();
			try
			{
				fileIO.CreateFolder(text);
				fileIO.CopyDirectoryFile(oldDirectoryStr, newDirectoryStr);
				fileIO.CreateFolder(text + "\\Images");
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message.ToString());
			}
		}
		public bool EditShopByShopID(string ShopIDarray, string Type)
		{
			SqlParameter[] array = new SqlParameter[2];
			array[0] = new SqlParameter("@ShopID", DbType.String);
			array[0].Value = ShopIDarray;
			array[1] = new SqlParameter("@Type", DbType.String);
			array[1].Value = Type;
			int num = this.conn.Execute("pr_EditShopByShopID", array);
			return num > 0;
		}
		public bool OpenOrCloseSecUrl(string ShopIDarray, string Value)
		{
			string sql = string.Concat(new string[]
			{
				"Update HLShop_Shop Set IsUseSecUrl = ",
				Value,
				"Where ShopID in (",
				ShopIDarray,
				")"
			});
			return this.conn.Execute(sql) > 0;
		}
		public bool deleteSecUrlByShopID(string ShopIDarray)
		{
			string sql = "Update HLShop_Shop Set SecUrl = '',IsUseSecUrl=0 Where ShopID in (" + ShopIDarray + ")";
			return this.conn.Execute(sql) > 0;
		}
		public DataTable SearchShopPerPage(int PageSize, int PageIndex, int Count, string SearchType, string SearchText, int SearchClassID, string ShopSalerName, string Product, string ShopPlace, string ShopItem, int SortType, string CommondShop, string SeniorShop, string BandShop, string OtherType)
		{
			bool flag = false;
			int num = 20;
			string text = " ShopIdentify=1 and  ShopStatus=1  and ";
			Shop_Class shop_Class = new Shop_Class(this.conn);
			DataTable dataTable = new DataTable();
			if (SearchClassID <= 0)
			{
				dataTable = shop_Class.GetRootClass();
			}
			string text2 = SearchClassID.ToString() + ",";
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				text2 = text2 + dataTable.Rows[i]["classid"].ToString() + ",";
			}
			if (text2.Length > 1)
			{
				text2 = text2.Remove(text2.Length - 1);
			}
			string text3 = text2;
			if (PageSize > 0)
			{
				num = PageSize;
			}
			int num2;
			if (PageIndex > 0)
			{
				num2 = PageIndex;
			}
			else
			{
				num2 = 1;
			}
			if (CommondShop != null && CommondShop != "" && CommondShop != "0")
			{
				text = text + "(ShopGroupID in(" + CommondShop + ")";
				flag = true;
			}
			if (flag)
			{
				text += ") AND ";
				flag = false;
			}
			if (SearchText != "" & SearchText != null)
			{
				text = text + " ShopName like '%" + SearchText + "%' AND";
				flag = true;
			}
			if (ShopSalerName != "" && ShopSalerName != null)
			{
				text = text + " ShopOwnerName like '%" + ShopSalerName + "%' AND";
				flag = true;
			}
			if (text3 != "")
			{
				text = text + " ShopCategoryID in (" + text3 + ") AND";
				flag = true;
			}
			if (ShopPlace != "" && ShopPlace != null)
			{
				text = text + " ShopAddress like '%" + ShopPlace + "%' AND";
				flag = true;
			}
			else
			{
				if (Product != "" && Product != null)
				{
					text = text + " ShopAddress like '%" + Product + "%' AND";
					flag = true;
				}
			}
			if (ShopItem != "" && ShopItem != null)
			{
				text = text + " ShopOperatorItem like '%" + ShopItem + "%' AND";
				flag = true;
			}
			if (OtherType != "" && OtherType != null)
			{
				if (OtherType != null)
				{
					if (OtherType == "recommend")
					{
						text += " RecommendShop =1 AND";
						flag = true;
					}
				}
			}
			if (flag)
			{
				text = text.Remove(text.Length - 3);
			}
			string text4;
			switch (SortType)
			{
			case 1:
				text4 = " HLShop_Shop.ShopID asc";
				break;
			case 2:
				text4 = " HLShop_Shop.ShopID desc";
				break;
			case 3:
				text4 = " HLShop_Shop.ShopRegDate asc";
				break;
			case 4:
				text4 = " HLShop_Shop.ShopRegDate desc";
				break;
			case 5:
				text4 = " HLShop_Shop.ShopGroupID asc";
				break;
			case 6:
				text4 = " HLShop_Shop.ShopGroupID desc";
				break;
			case 7:
				text4 = " HLShop_Shop.ShopClick asc";
				break;
			case 8:
				text4 = " HLShop_Shop.ShopClick desc";
				break;
			case 9:
				text4 = " HLShop_Shop.ShopCredit asc";
				break;
			case 10:
				text4 = " HLShop_Shop.ShopCredit desc";
				break;
			default:
				text4 = " HLShop_Shop.ShopID desc";
				break;
			}
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@PageSize", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@PageIndex", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@Counts", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@strWhere", SqlDbType.VarChar, 3000, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@OrderBy", SqlDbType.VarChar, 100, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", "")
			};
			if (num > 0)
			{
				array[1].Value = num;
			}
			else
			{
				array[1].Value = DBNull.Value;
			}
			if (num2 > 0)
			{
				array[2].Value = num2;
			}
			else
			{
				array[2].Value = DBNull.Value;
			}
			if (Count > 0)
			{
				array[3].Value = Count;
			}
			else
			{
				array[3].Value = DBNull.Value;
			}
			if (text == null)
			{
				array[4].Value = DBNull.Value;
			}
			else
			{
				array[4].Value = text;
			}
			if (text4 == null)
			{
				array[5].Value = DBNull.Value;
			}
			else
			{
				array[5].Value = text4;
			}
			DataTable result;
			if (text != "")
			{
				result = this.conn.GetDataTable("Pr_SearchShopListPerPage", array);
			}
			else
			{
				result = null;
			}
			return result;
		}
		public bool IsSecUrl(int shopID)
		{
			DataTable dataTable = this.conn.GetDataTable("Select IsUseSecUrl From  HL_ShopGroup Where ID\r\nIn (Select ShopGroupID From HLShop_Shop Where ShopID=" + shopID + ")");
			Config config = new Config();
			DataRow config2 = config.config;
			return dataTable.Rows[0]["IsUseSecUrl"].ToString() == "1";
		}
		public HtmlGenericControl ChangeSkin(string cssFile)
		{
			HtmlGenericControl htmlGenericControl = new HtmlGenericControl("link");
			htmlGenericControl.Attributes["rel"] = "stylesheet";
			htmlGenericControl.Attributes["type"] = "text/css";
			htmlGenericControl.Attributes["href"] = cssFile;
			return htmlGenericControl;
		}
		public DataTable getShopTemByShopID(int ShopID)
		{
			return this.conn.GetDataTable("Select * From HLShop_ShopTemplate Where ShopID = " + ShopID);
		}
		public bool setShopTempTele(int TempID, int ShopID)
		{
			this.conn.Execute("Update HLShop_ShopTemplate Set IsChecked=0 Where ShopID = " + ShopID + " and IsChecked = 1");
			return this.conn.Execute("Update HLShop_ShopTemplate Set IsChecked=1 Where ShopTempteleID = " + TempID) > 0;
		}
		public bool addShopTemptele(int tempID, int ShopID)
		{
			DataTable dataTable = this.conn.GetDataTable("Select * From HL_ShopTemplate Where ShopTempID = " + tempID);
			FileIO fileIO = new FileIO();
			Config config = new Config();
			DataRow config2 = config.config;
			string truePath = Fetch.GetTruePath("Shop/" + ShopID.ToString() + "/" + dataTable.Rows[0]["TempteleName"].ToString());
			string truePath2 = Fetch.GetTruePath(dataTable.Rows[0]["TempTeleUrl"].ToString());
			truePath2.Substring(0, truePath2.Length - 1);
			string text = dataTable.Rows[0]["TempteleName"].ToString();
			int num = 0;
			string text2 = string.Concat(new string[]
			{
				"Shop /",
				ShopID.ToString(),
				"/",
				dataTable.Rows[0]["TempteleName"].ToString(),
				"images/main.gif"
			});
			string sql = "Select * From HLShop_ShopTemplate Where TempteleName = '" + text + "'";
			int num2 = this.conn.ExecuteCount(sql);
			bool result;
			if (num2 == 0)
			{
				string sql2 = string.Format("Insert Into HLShop_ShopTemplate (TempteleName,ShopID,IsChecked,PicUrl) Values \r\n('{0}',{1},{2},'{3}')", new object[]
				{
					text,
					ShopID,
					num,
					text2
				});
				if (this.conn.Execute(sql2) > 0)
				{
					fileIO.CopyDirectoryFile(truePath2, truePath);
					result = true;
				}
				else
				{
					result = false;
				}
			}
			else
			{
				result = false;
			}
			return result;
		}
	}
}
